# utils/exceptions.py
from apps.common.utils.response import *
from rest_framework.views import exception_handler
from rest_framework.response import Response


def custom_exception_handler(exc, context):
    print('exc, contex', exc, context)
    response = exception_handler(exc, context)
    if response is not None:
        response.data['status_code'] = response.status_code
    elif isinstance(exc, Exception):
        return Response(response_message('错误异常'))
    # elif isinstance(exc, sdsd ):
    #     print('res', response)
    #     response = response_message('错误异常')
    return None

class VerifyException(Exception):
    def __init__(self, message="", store_type=None):
        self.message = message
        self.store_type = store_type
        super().__init__(self.message)

    def __str__(self):
        return f'{self.message} {"(类型: %s)" % self.store_type if self.store_type else ""}'

